//
//  WPDataMap.m
//  PhnixHome
//
//  Created by Levy Xu on 2018/3/6.
//  Copyright © 2018年 Levy Xu. All rights reserved.
//

#import "WPDataMap.h"
#import <GizWifiSDK/GizWifiSDK.h>

@implementation WPFault

@end

@implementation WPData

-(UIImage *)waterLevelImage {
    if (_PureWaterTDS > 200) {
        return UIImageMake(@"water_level_4");
    } else if (_PureWaterTDS > 100) {
        return UIImageMake(@"water_level_3");
    } else if (_PureWaterTDS > 50) {
        return UIImageMake(@"water_level_2");
    } else {
        return UIImageMake(@"water_level_1");
    }
}

-(UIColor *)waterLevelColor {
    if (_PureWaterTDS > 200) {
        return UIColorMakeWithHex(@"48668b");
    } else if (_PureWaterTDS > 100) {
        return UIColorMakeWithHex(@"4375b3");
    } else if (_PureWaterTDS > 50) {
        return UIColorMakeWithHex(@"2a78d7");
    } else {
        return UIColorMakeWithHex(@"4898fa");
    }
}

-(NSString *)waterLevelTips {
    if (_PureWaterTDS > 200) {
        return NSLocalizedString(@"water_level_4", nil);
    } else if (_PureWaterTDS > 100) {
        return NSLocalizedString(@"water_level_3", nil);
    } else if (_PureWaterTDS > 50) {
        return NSLocalizedString(@"water_level_2", nil);
    } else {
        return NSLocalizedString(@"water_level_1", nil);
    }
}

-(NSString *)statusString {
    if (self.Status == 0) {
        return NSLocalizedString(@"state_wash", nil);
    } else if (self.Status == 1) {
        return NSLocalizedString(@"state_make_water", nil);
    } else if (self.Status == 2) {
        return NSLocalizedString(@"state_checking", nil);
    } else {
        return NSLocalizedString(@"state_standby", nil);
    }
}

-(NSString *)stringForAlert {
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 0; i < 4; i++) {
        if ([self filter_left:i] <= 0) {
            [array addObject:[WPData filterString:i]];
        }
    }
    return [array componentsJoinedByString:@"、"];
}

-(NSInteger)filter_left:(NSInteger)index {
    return [self filter_life:index] - [self filter_used:index];
}

-(NSInteger)filter_used:(NSInteger)index {
    if (index == 0) {
        return self.UsedTime_Filter1;
    } else if (index == 1) {
        return self.UsedTime_Filter2;
    }  else if (index == 2) {
        return self.UsedTime_Filter3;
    }  else {
        return self.UsedTime_Filter4;
    }
}

-(NSInteger)filter_life:(NSInteger)index {
    if (index == 0) {
        return self.LifeTime_Filter1;
    } else if (index == 1) {
        return self.LifeTime_Filter2;
    }  else if (index == 2) {
        return self.LifeTime_Filter3;
    }  else {
        return self.LifeTime_Filter4;
    }
}

+(NSString *)filterKey:(NSInteger)index {
    if (index == 0) {
        return @"UsedTime_Filter1";
    } else if (index == 1) {
        return @"UsedTime_Filter2";
    }  else if (index == 2) {
        return @"UsedTime_Filter3";
    }  else {
        return @"UsedTime_Filter4";
    }
}

+(NSString *)filterString:(NSInteger)index {
    if (index == 0) {
        return NSLocalizedString(@"water_filter_1", nil);
    } else if (index == 1) {
        return NSLocalizedString(@"water_filter_2", nil);
    }  else if (index == 2) {
        return NSLocalizedString(@"water_filter_3", nil);
    }  else {
        return NSLocalizedString(@"water_filter_4", nil);
    }
}

+(UIImage *)filterImage:(NSInteger)index {
    if (index == 0) {
        return UIImageMake(@"water_filter_1");
    } else if (index == 1) {
        return UIImageMake(@"water_filter_2");
    }  else if (index == 2) {
        return UIImageMake(@"water_filter_3");
    }  else {
        return UIImageMake(@"water_filter_4");
    }
}

+(NSString *)filter_url:(NSInteger)index {
    if (index == 0) {
        return @"http://phnix.5mall.com/mobile/product/content/6871.jhtml";
    } else if (index == 1) {
        return @"http://phnix.5mall.com/mobile/product/content/6872.jhtml";
    } else if (index == 2) {
        return @"https://phnixgd.tmall.com/";
    } else {
        return @"http://phnix.5mall.com/mobile/product/content/6873.jhtml";
    }
}

+(NSAttributedString *)attributedStatusString:(NSString *)text {
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"state_current", nil)
                                                                               attributes:CodeAttributes2(18, @"4898fa")];
    NSAttributedString *string2 = [[NSMutableAttributedString alloc] initWithString:text
                                                                         attributes:CodeAttributes2(20, @"000000")];
    [string appendAttributedString:string2];
    return string;
}

@end

@implementation WPDataMap

@end
